import os
import redis as redis


class RedisSupport:
    __instance = None
    __redis = None

    def __new__(cls, *args, **kwargs):
        if not cls.__instance:
            cls.__instance = super().__new__(cls, *args, **kwargs)
            RedisSupport.__redis = redis.Redis(host=os.getenv('REDIS_IP_ADDR'),
                                           port=os.getenv('REDIS_PORT'),
                                           db=0,
                                           password=os.getenv('REDIS_PASSWORD'))
        return cls.__instance

    @staticmethod
    def redis():
        return RedisSupport.__redis
